/**
 * Copyright 2013 yangming.liu<liuyangming@gmail.com>.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, see <http://www.gnu.org/licenses/>.
 */
package org.bytesoft.openjta.archive;

import java.util.ArrayList;
import java.util.List;

import org.bytesoft.openjta.TransactionConstants;
import org.bytesoft.openjta.TransactionContext;
import org.bytesoft.openjta.TransactionStatus;

public class TransactionArchive extends AbstractArchive {
	private static final long serialVersionUID = 1L;

	protected int transactionMode = TransactionConstants.TX_MODE_NONE;

	protected TransactionStatus transactionStatus;
	protected TransactionContext transactionContext;

	protected boolean localResourceAllowed = true;
	protected boolean nativeContainsLocalResource = false;

	protected final List<TerminatorArchive> terminatorArchives = new ArrayList<TerminatorArchive>();
	protected final List<XAResourceArchive> xaResourceArchives = new ArrayList<XAResourceArchive>();

	public int getTransactionMode() {
		return transactionMode;
	}

	public void setTransactionMode(int transactionMode) {
		this.transactionMode = transactionMode;
	}

	public TransactionStatus getTransactionStatus() {
		return transactionStatus;
	}

	public void setTransactionStatus(TransactionStatus transactionStatus) {
		this.transactionStatus = transactionStatus;
	}

	public TransactionContext getTransactionContext() {
		return transactionContext;
	}

	public void setTransactionContext(TransactionContext transactionContext) {
		this.transactionContext = transactionContext;
	}

	public boolean isLocalResourceAllowed() {
		return localResourceAllowed;
	}

	public void setLocalResourceAllowed(boolean localResourceAllowed) {
		this.localResourceAllowed = localResourceAllowed;
	}

	public boolean isNativeContainsLocalResource() {
		return nativeContainsLocalResource;
	}

	public void setNativeContainsLocalResource(boolean nativeContainsLocalResource) {
		this.nativeContainsLocalResource = nativeContainsLocalResource;
	}

	public List<TerminatorArchive> getTerminatorArchives() {
		return this.terminatorArchives;
	}

	public List<XAResourceArchive> getXAResourceArchives() {
		return this.xaResourceArchives;
	}

	public void clone(TransactionArchive that) {
		this.prepareStarted = that.prepareStarted;
		this.prepareResult = that.prepareResult;
		this.commitStarted = that.commitStarted;
		this.commitResult = that.commitResult;
		this.rollbackStarted = that.rollbackStarted;
		this.rollbackResult = that.rollbackResult;
		this.transactionMode = that.transactionMode;
		this.transactionStatus = that.transactionStatus;
		this.transactionContext = that.transactionContext;
		this.localResourceAllowed = that.localResourceAllowed;
		this.nativeContainsLocalResource = that.nativeContainsLocalResource;
		this.terminatorArchives.addAll(that.terminatorArchives);
		this.xaResourceArchives.addAll(that.xaResourceArchives);
	}
}
